#include<iostream>
#include<functional>
#include<map>

int add (int a,int b,int c)
{
    return a+b+c;
}
int minu(int a,int b)
{
    return a-b;
}
int mul(int a,int b)
{
    return a*b;
}
int divide(int a,int b)
{
    return a/b;
}

std::map<char,std::function<int(int,int)>> m;

int Calculate(int a,int b,char symbol)
{
    return m[symbol](a,b);
}

int main()
    //适配器:将原有逻辑改动以后适应新的逻辑
{   //函数绑定器
    //std::placeholders:占位符
    //auto f = std::bind(add,std::placeholders::_1,std::placeholders::_2,0);
    auto f=[](int a,int b){return add(a,b,0);};
    m['+']=f;
    m['-']=minu;
    m['*']=mul;
    m['/']=divide;



    return 0;
}



